package cn.cms.mongo;

import org.jfaster.mango.operator.Mango;
import org.jfaster.mango.plugin.spring.AbstractMangoFactoryBean;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * Created by justin on 2017/12/13.
 */
public class MyMangoFactoryBean extends AbstractMangoFactoryBean implements ApplicationContextAware {
    private ApplicationContext applicationContext;

    public MyMangoFactoryBean() {
    }

    public Mango createMango() {
        Mango mango = (Mango) this.applicationContext.getBean(Mango.class);
        mango.addInterceptor(new MysqlPageInterceptor());
        return mango;
    }

    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}